/*
 * @Author: szx
 * @Date: 2022-03-08 15:56:05
 * @LastEditTime: 2022-03-08 15:57:33
 * @Description:
 * @FilePath: \leetcode\100-199\108\108_2.js
 */
/**
 * @param {number[]} nums
 * @return {TreeNode}
 */
var sortedArrayToBST = function (nums) {
    const dfs = function (left, right) {
        const mid = Math.floor((left + right) / 2);
        const node = new TreeNode(nums[mid]);
        node.left = dfs(left, mid - 1);
        node.right = dfs(mid + 1, right);
        return node;
    };
    return dfs(0, nums.length - 1);
};
